<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="contact.domain.DAOContact"%>
<%@page import="contact.domain.Contact"%>
<%@page import="contact.domain.PhoneNumber"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" media="screen" href="style.css">
<% 
DAOContact dao = new DAOContact();
Long id = new Long (request.getParameter("id"));
Contact contact = dao.getContact(id);
String firstname = contact.getFirstName();
String lastname = contact.getLastName();
String email = contact.getEmail();
String street = contact.getAddress().getStreet();
String city = contact.getAddress().getCity();
String zip = contact.getAddress().getZip();
String country = contact.getAddress().getCountry();
String mobile = "";
String home = "";
String job = "";
for (PhoneNumber phone : contact.getProfiles()){
	if (phone.getPhoneKind().equals("MOBILE")) mobile = phone.getPhoneNumber();
	if (phone.getPhoneKind().equals("HOME")) home = phone.getPhoneNumber();
	if (phone.getPhoneKind().equals("JOB")) job = phone.getPhoneNumber();
}
String maintitle = firstname.charAt(0) + ". " + lastname;
String title = firstname + " " + lastname + " - " + id;
%>
<title><%=maintitle %></title>
</head>
<body>
<jsp:include page="menu.html" />
<form id="showcontact" action="updateContact2.jsp">
	<h1><%=title %></h1>
	<input type="hidden" name="id" value="<%=id %>"></input>		
	<p>
		<label for="firstname">First name</label>
		<input name="firstname" type="text" value="<%=firstname %>" readonly />		
	</p>
	<p>
		<label for="lastname">Last name</label>
		<input name="lastname" type="text" value="<%=lastname %>" readonly ></input>		
	</p>
	<p>
		<label for="email">Email</label>
		<input name="email" type="text" value="<%=email %>" readonly ></input>		
	</p>
	<h1></h1>
	<p>
		<label for="street">Street</label>
		<input name="street" type="text" value="<%=street %>" readonly ></input>		
	</p>
	<p>
		<label for="city">City</label>
		<input name="city" type="text" value="<%=city %>" readonly ></input>		
	</p>
	<p>
		<label for="zip">Zip</label>
		<input name="zip" type="text" value="<%=zip %>" readonly ></input>		
	</p>
	<p>
		<label for="country">Country</label>
		<input name="country" type="text" value="<%=country %>" readonly ></input>		
	</p>
	<h1></h1>
	<p>
		<label for="mobile">Mobile</label>
		<input name="mobile" type="text" value="<%=mobile %>" readonly />		
	</p>
	<p>
		<label for="home">Home</label>
		<input name="home" type="text" value="<%=home %>" readonly />		
	</p>
	<p>
		<label for="job">Job</label>
		<input name="job" type="text" value="<%=job %>" readonly />		
	</p>
	<input type="submit" value="Modify"/>
</form>
</body>
</html>